#ifndef __MeshAnimation_H__
#define __MeshAnimation_H__

#include "defines.h"
#include "video/Array.h"
#include "video/SubMesh.h"
#include <vector>
#include <map>
namespace KEngine
{

class SubMeshAnimation
{
public:
	struct Frame
	{
		TimeValue						t;
		Array<SubMesh::VertexData>	verts;
		Array<SubMesh::NormalData>	normals;
	};
	typedef std::vector<Frame*> MeshFrameList;

	SubMeshAnimation();
	virtual ~SubMeshAnimation();

	void			addFrame(Frame* frame);
	Frame*			getFrame(int idx);
	int				getNumFrames();

protected:
	MeshFrameList	mFrameList;
};

/**
	Set of sub mesh animations, they may have different frame counts, but
	must share the same key frame time
*/
class MeshAnimation
{
public:
	typedef std::map<std::string, SubMeshAnimation*> SubMeshAnimSet;
	typedef SubMeshAnimSet::iterator SubMeshAnimIterator;
	typedef SubMeshAnimSet::const_iterator SubMeshAnimConstIterator;
	typedef SubMeshAnimSet::value_type SubMeshAnimValue;

public:
	MeshAnimation();
	virtual ~MeshAnimation();

	bool				load(const char* filename);

	bool				addAnimation(const std::string& subMeshName, SubMeshAnimation* animation);
	SubMeshAnimation* getAnimation(const std::string& subMeshName);
	SubMeshAnimation* getLongestAnimation();

protected:
	SubMeshAnimSet		mAnimationSet;
};

}

#endif //